home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / curdle.com / CURDLASM.ARC / CURDL.ASM next >
Encoding:
Assembly Source File  |  1989-01-10  |  4.4 KB  |  109 lines

  1.     
  2.     ; 
  3.     ;Function cURDLE(CurDir: Char; VAR CurRow, CurCol: Byte): Boolean;
  4.     ;
  5.     ;Public domain software by: John M. Majkrzak
  6.     ;                           1880 Todd Dr
  7.     ;                           Arden Hills, MN  55112
  8.     ;                           CIS# 76617,264
  9.     ;                   
  10.     ;This procedure will return the coordinates for the next cursor move. 
  11.     ;For use with Turbo Pascal.
  12.     ;Example call from TP:  If cURDL(CurDir, CurRow, CurCol) then begin...
  13.     ;Boolean function returns true if CurDir value was one listed below.
  14.     ;CurRow and CurCol values are where the cursor should go next.
  15.     ;There is no checking against register overflow because I don't need
  16.     ;to be concerned with a monster sized display.
  17.     ;This and all the related files are my first output as an assembler
  18.     ;programmer and made public domain as a celebration.
  19.  
  20.     include pasmac.asm      
  21.  
  22.       lArr equ 75
  23.       rArr equ 77
  24.       uArr equ 72
  25.       dArr equ 80
  26.  
  27.     data segment word public
  28.       assume ds:data
  29.       extrn cwMin:  Word               ;Commonly assigned to TPs WindMin and
  30.       extrn cwMax:  Word               ;WindMax variables by absolute ref.
  31.       extrn cwPage: Byte               ;You must specify a page (usually 0). 
  32.     data ends
  33.  
  34.     code segment byte public
  35.       assume cs:code
  36.  
  37.     OnStack struc
  38.       OldBP       DW ?
  39.       RetAddr     DD ?                 ;far RetAddr DD, near is DW
  40.       AddrCurCol  DD ?                 ;CurCol byte. Turbo Pushes a pointer.
  41.       AddrCurRow  DD ?                 ;CurRow byte
  42.       Direction   DW ?                 ;Which way to go. Passed as char;
  43.     OnStack ends
  44.  
  45.     cURDL proc far
  46.       public cURDL
  47.       m_Entry  
  48.       m_WhereRC <[cwPage]>             ;DH = CurRow, DL = CurCol
  49.       mov  bx,[cwMin]                  ;BH = MinRow, BL = MinCol
  50.       mov  cx,[cwMax]                  ;CH = MaxRow, CL = MaxCol
  51.       mov  ax,[bp.direction]           ;AL tells direction
  52.       mov  ah, -1                      ;AH holds temp TF function result
  53.       cmp  al, lArr                    ;Want to move left?
  54.       jne  MaybeRDU
  55.       cmp  dl,bl                       ;we need to set col to max if it is
  56.       jle  SetMaxCol                   ;too small already.
  57.       dec  dl                          ;otherwise just decrement the curcol
  58.       jmp  short DoneReturn
  59.     SetMaxCol:
  60.       mov  dl,cl
  61.     CmpRow_Dec:                        ;test to see if we can decrement the 
  62.       cmp  dh, bh                      ;row any further.  If we can then just
  63.       ja   DecCurRow                   ;dec the row
  64.       mov  dh, ch                      ;otherwise set CurRow to max
  65.       inc  dh                          ;and increment it because
  66.     DecCurRow:
  67.       Dec  dh                          ;decrement CurRow
  68.       jmp  Short DoneReturn
  69.  
  70.     MaybeRDU:
  71.       cmp  al,rArr                     ;Want to move right?
  72.       jne  MaybeDU
  73.       inc  dl                          ;If so then inc CurCol then test to see 
  74.       cmp  dl,cl                       ;if it is too big
  75.       jle  DoneReturn
  76.       mov  dl,bl                       ;if so then set CurCol to MinCol
  77.     IncCurRow:
  78.       inc  dh                          ;and increment the row
  79.       cmp  dh,ch                       ;then test to see if it is too big
  80.       jle  DoneReturn
  81.       mov  dh,bh                       ;if so then set CurRow to MinRow
  82.       jmp  short DoneReturn
  83.  
  84.     MaybeDU:
  85.       cmp  al,dArr                     ;want to move down?
  86.       jne  MaybeU
  87.       jmp  IncCurRow                   ;if so then increment the row.
  88.  
  89.     MaybeU:
  90.       cmp  al,uArr                     ;want to move up screen?
  91.       jne  NoMatch                     ;Input was not a cursor key.
  92.       jmp  CmpRow_Dec                  ;if so then decrement the row.
  93.  
  94.     NoMatch:
  95.       inc  ah                          ;Make temp result false.
  96.     DoneReturn:
  97.       mov  al,ah                       ;Place TF result in AL for return
  98.       inc  dh                          ;Increment the results for use with
  99.       inc  dl                          ;GoToXY() 
  100.       sub  dh, bh                      ;Subtract the WindMin offset so GoToXY()
  101.       sub  dl, bl                      ;will place the cursor inside window.
  102.       m_RetData <AddrCurRow>, <dh>
  103.       m_RetData <AddrCurCol>, <dl>
  104.       m_Exit
  105.  
  106.   cURDL endp
  107.   code  ends
  108.   end
  109.